package App.Job;

import App.Config.ScheduleConifg;
import App.Model.ConnectinManager;
import App.Model.ConnectionInfo;
import App.Repository.TaskAuthRepository;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * Created by xw on 2019/5/15.
 */

@Component
public class AuthJobImprove {

    @Autowired
    private ScheduleConifg _scheduleConfig;


    public void execute() {

        System.out.println("i am auth job");

        if (!_scheduleConfig.getIsactive()) {
            return;
        }

        try {

            ConnectionInfo _conn = ConnectinManager.getConnectionInfo();
            TaskAuthRepository _taskRepository = new TaskAuthRepository();
            _taskRepository.passUserAuth(_conn.getUrl(), _conn.getUsername(), _conn.getPassword());

        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }

}
